//
//  LHNetworkHandleWithPost.m
//  Knight_Tour
//
//  Created by Bruce_Lin on 15/5/19.
//  Copyright (c) 2015年 TouchOne. All rights reserved.
//

#import "LHNetworkHandleWithPost.h"
#import "AFNetworking.h"

@interface LHNetworkHandleWithPost ()
@end

@implementation LHNetworkHandleWithPost

+(void)getDataWithURL:(NSString *)str Body:(NSString *)body completion:(void (^)(id))block
{
    
    NSString *path = [NSString stringWithFormat:@"%@%@",str,body];
    //创建AFN请求管理者对象
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    // 设置响应数据支持类型
    [manager.responseSerializer setAcceptableContentTypes:[NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html",@"text/css",@"text/plain", nil]];
   
    [manager POST:path parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSLog(@"请求成功");
        id result = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        block(result);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"请求失败");
    }];
    
}

@end
